package com.bluetooth.demo.ui;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bluetooth.demo.MyApplication;
import com.bluetooth.demo.R;
import com.bluetooth.demo.model.Student;

public class MineFragment extends Fragment {

    private View mCurrentView;
    private TextView tv_name;
    private TextView tv_sid;
    private TextView tv_phone;
    private TextView tv_ssid;
    private TextView tv_college;
    private TextView tv_sclass;
    private TextView tv_sex;
    private TextView tv_email;

    public MineFragment() {
        // Required empty public constructor
    }

    public static MineFragment newInstance() {
        MineFragment fragment = new MineFragment();
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        mCurrentView = inflater.inflate(R.layout.fragment_mine, container, false);
        initView(mCurrentView);

        Student student = MyApplication.getInstance().getStudent();
        if (student != null) {

            tv_name.setText(student.getSname());
            tv_sid.setText(student.getSid());
            tv_phone.setText(student.getStel());
            tv_ssid.setText(student.getSsid());
            tv_college.setText(student.getScollege());
            tv_sclass.setText(student.getSclass());
            tv_sex.setText(student.getSsex());
            tv_email.setText(student.getSemail());
        }

        return mCurrentView;
    }


    private void initView(View mCurrentView) {
        tv_name = (TextView) mCurrentView.findViewById(R.id.tv_name);
        tv_sid = (TextView) mCurrentView.findViewById(R.id.tv_sid);
        tv_phone = (TextView) mCurrentView.findViewById(R.id.tv_phone);
        tv_ssid = (TextView) mCurrentView.findViewById(R.id.tv_ssid);
        tv_college = (TextView) mCurrentView.findViewById(R.id.tv_college);
        tv_sclass = (TextView) mCurrentView.findViewById(R.id.tv_sclass);
        tv_sex = (TextView) mCurrentView.findViewById(R.id.tv_sex);
        tv_email = (TextView) mCurrentView.findViewById(R.id.tv_email);
    }
}
